﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Caching
{
    public interface ICache
    {

        /// <summary>
        /// 索引器  获取缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object this[string key]
        {
            get;
        }
        /// <summary>
        /// 增加一个缓存 
        /// </summary>
        /// <param name="key">缓存名称</param>
        /// <param name="value">缓存值</param>
        /// <returns></returns>
        bool AddObject(string key, string value);

        /// <summary>
        /// 增加一个缓存
        /// </summary>
        /// <param name="key">缓存名称</param>
        /// <param name="value">缓存值</param>
        /// <param name="ExpiresDateTime">过期时间</param>
        /// <returns></returns>
        bool AddObject(string key, string value, DateTime ExpiresDateTime);

        /// <summary>
        /// 根据缓存Key 移除缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool RemoveObject(string key);

        /// <summary>
        /// 根据key 获取一个缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object GetObject(string key);

        /// <summary>
        /// 根据expression 匹配来获取  缓存
        /// </summary>
        /// <param name="expression">匹配表达式(正则)</param>
        /// <returns></returns>
        Dictionary<string, object> GetObjectByExpression(string expression);


        /// <summary>
        /// 移除Cache 根据正则表达式
        /// </summary>
        /// <param name="expression">匹配表达式</param>
        /// <returns></returns>
        void RemoveObjectByExpression(string expression);

    }
}
